<template>
  <div class="hwget-container">
    <div class="header">
    <span>当前位置：</span>
<el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item>数据查询</el-breadcrumb-item>
  <el-breadcrumb-item :to="{path:'/student/hwsubmit'}">作业查询</el-breadcrumb-item>
  <el-breadcrumb-item>作业详情</el-breadcrumb-item>
</el-breadcrumb></div>
    <div class="hwcontent">
      <h1 class="arti-title">{{hwdata.hwtitle}}</h1>
      <p class="arti-metas">
        <span class="arti-time">发布日期：{{hwdata.posttime}}</span>
        <span class="arti-finaltime">截止日期：{{hwdata.finaltime}}</span>
        <span class="arti-from">课程：{{hwdata.coursename}}</span>
      </p>
      <div class="article">
        <p>{{hwdata.desc}}</p>
      </div>
    </div>
    <el-button type="primary" @click="homeworksubmit">{{hwdata.ishwsubmit=='是'?'修改作业':'提交作业'}}</el-button>
    <el-dialog
  title="作业提交"
  :visible.sync="dialogVisible"
  width="30%"
  :before-close="handleClose">
  <submit></submit>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>
  </div>
</template>

<script>
import submit from '../Submitform/index.vue'
import http from '@/api/studentapi'
export default {
  name: '',
  data () {
    return {
      hwdata:{},
      dialogVisible: false,
    }
  },
  methods: {
    homeworksubmit(){
      let nowtime=Date.now();
      let finaltime=Date.parse(this.hwdata.finaltime);
      if(nowtime<=finaltime){
              this.dialogVisible= true;
      }
      else{
        this.$Toast({
          content:"对不起，当前已过作业提交日期！",
          type:"error"
        })
      }
    },
    handleClose(){
      this.dialogVisible= false;
    }
  },
  components:{
    submit
  },
  mounted () {
    let stuname=localStorage.getItem("username");
    let courseid=this.$route.params["courseid"];
    let hwid=this.$route.params["hwid"];
    http.getconcretehw({courseid:courseid,hwid:hwid,stuname:stuname}).then((res)=>{
      if(res.status==200){
        this.hwdata=res.data.hwdata;
      }
    },(error)=>{return Promise.reject(new Error("获取服务器数据失败！"))})
  }
}
</script>

<style lang="less" scoped>
.hwget-container {
    text-align: center;
  .header {
      text-align: left;
  height: 30px;
  line-height: 30px;
  border-bottom: 1px solid #ccc;
  .el-breadcrumb {
  display: inline-block;
}
  &>span {
    font-size: 16px;
  }
}
.hwcontent {
  margin-top: 20px;
  .arti-title {
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 28px;
  }
.arti-metas {
  padding-bottom: 10px;
  border-bottom: 1px solid #ccc;
    span {
    margin: 0 10px;
    color: #999;
    font-size: 12px;
    display: inline-block;
  }
}
.article {
  overflow: scroll !important;
  font-size: 15px;
  text-align: justify;
  p{
    line-height: 1.7;
    margin: 8px 0;
    font-family: "微软雅黑";
  }
}
}

}
</style>
